unit MyDebugger;

interface

uses
  IdIOHandlerSocket;

type
  TMyDebugger = class(TIdIOHandlerSocket)
  protected
    FBytesPerSecond: Integer;
  public
    function Recv(var ABuf; ALen: integer): Integer; override;
  published
    property BytesPerSecond: Integer read FBytesPerSecond write FBytesPerSecond;
  end;

implementation

uses
  Main,
  IdGlobal;

{ TMyDebugger }

function TMyDebugger.Recv(var ABuf; ALen: integer): integer;
var
  LWaitTime: Cardinal;
  LRecvTime: Cardinal;
begin
  if FBytesPerSecond > 0
  then begin
       LRecvTime := IdGlobal.GetTickCount;
       Result := inherited Recv(ABuf, ALen);
       LRecvTime := GetTickDiff(LRecvTime, IdGlobal.GetTickCount);
       LWaitTime := (Result * 1000) div FBytesPerSecond;
       if LWaitTime > LRecvTime
       then begin
            IdGlobal.Sleep(LWaitTime - LRecvTime);
            end;
       end
  else begin
       Result := inherited Recv(ABuf, ALen);
       end;
end;

end.
